﻿using AOOR.Utilities;
using System;
using System.Collections.Generic;
using System.Linq;
using Website.Interfaces;

namespace Website.Infrastructure
{
    public class DeviceDetector : IDeviceDetector
    {
        private string _userAgent;

        public DeviceDetector(string userAgent)
        {
            _userAgent = userAgent;
        }

        public bool IsPhoneDevice()
        {
            var devices = new[] { "iPhone", "iPod", "BlackBerry", "Windows Phone" };
            return _userAgent.ContainsAny(devices, StringComparison.OrdinalIgnoreCase);
        }

        public bool IsTabletDevice()
        {
            var devices = new[] { "iPad", "Playbook", "Kindle Fire", "Transformer", "Xoom" };
            return _userAgent.ContainsAny(devices, StringComparison.OrdinalIgnoreCase);
        }
    }
}